/*
 * Powered By fanrenqij.com
 * Since 2017 - 2017
 */

package com.fanrenqiji.modules.business.parentdailyscore.dao;

import com.fanrenqiji.common.persistence.BaseDao;
import com.fanrenqiji.common.persistence.BaseDaoImpl;
import com.fanrenqiji.entity.ParentDailyScoreEntity;
import lombok.Data;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
/**
 * 持久化接口
 */
public interface ParentDailyScoreDao extends ParentDailyScoreDaoCustom, CrudRepository<ParentDailyScoreEntity, Long> {

    @Query("from ParentDailyScoreEntity where delFlag='" + ParentDailyScoreEntity.DEL_FLAG_NORMAL + "' order by id desc")
    public List<ParentDailyScoreEntity> findAllList();


    @Query("from ParentDailyScoreEntity where delFlag='" + ParentDailyScoreEntity.DEL_FLAG_NORMAL + "' and status =?1 order by id")
    public List<ParentDailyScoreEntity> findParentDailyScoreEntityByStatus(int status);

    @Modifying
    @Query("update ParentDailyScoreEntity set delFlag='" + ParentDailyScoreEntity.DEL_FLAG_DELETE + "' where id = ?1 ")
    void deleteById(Long id);

    @Query("from ParentDailyScoreEntity where delFlag='" + ParentDailyScoreEntity.DEL_FLAG_NORMAL + "' and parent.id =?1 and date=?2 order by id")
    public  List<ParentDailyScoreEntity> getbyTimePid(Long pid, Timestamp date);

}


interface ParentDailyScoreDaoCustom extends BaseDao<ParentDailyScoreEntity> {
}

@Repository
class ParentDailyScoreDaoImpl extends BaseDaoImpl<ParentDailyScoreEntity> implements ParentDailyScoreDaoCustom {

}
